package com.project.xsf.controller;

import com.alibaba.fastjson.JSONObject;
import com.project.junM.entity.TMember;
import com.project.xsf.entity.TAssess;
import com.project.xsf.entity.TAssessAnswer;
import com.project.xsf.entity.TAssessQuestion;
import com.project.xsf.entity.TBodyType;
import com.project.xsf.service.TAssessService;
import com.project.xsf.service.TBodyTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/tBodyType")
public class TBodyTypeController {
    @Autowired
    private TBodyTypeService tBodyTypeService;
    @PostMapping("/queryUserIfWritreBodyAnswer")
    public Boolean queryUserIfWritreBodyAnswer(HttpSession session){
        //判断用户是否填写体质问卷
        Boolean aBoolean = tBodyTypeService.queryByMemberId(session);
        return aBoolean;
    }
    @PostMapping("/addTBodyType")
    public void addTBodyType(@RequestBody String answers,HttpSession session){
        TAssessQuestion[][] objects = JSONObject.parseObject(answers, TAssessQuestion[][].class);
        tBodyTypeService.addTBodyType(objects, session);
    }

}
